﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BanVeXemPhim_Presentation
{
    public partial class UserControlMenuAdmin : UserControl
    {
        public UserControlMenuAdmin()
        {
            InitializeComponent();
        }

        public delegate void QuanLyPhim();
        public event QuanLyPhim EventQuanLyPhim;

        public delegate void QuanLyRapChieu();
        public event QuanLyRapChieu EventQuanLyRapChieu;

        public delegate void QuanLyNhanVien();
        public event QuanLyNhanVien EventQuanLyNhanVien;

        public delegate void ThongKeDoanhThu();
        public event ThongKeDoanhThu EventThongKeDoanhThu;

        public delegate void ThongKeKetQuaLamViec();
        public event ThongKeKetQuaLamViec EventThongKeKetQuaLamViec;

        public delegate void XepLicChieu();
        public event XepLicChieu EventXepLichChieu;

        public delegate void ThemDoiTuongMua();
        public event ThemDoiTuongMua EventThemDoiTuongMua;

        public delegate void ThietLapMucGiaVe();
        public event ThietLapMucGiaVe EventThietLapMucGia;

        private void buttonThongKe_Click(object sender, EventArgs e)
        {
            if(ThongKeisVisible==false)
            {
                ThongKeVisible(true);
                ThongKeisVisible = true;
            }
            else 
                ThongKeVisible(false);
        }

        private bool ThongKeisVisible = false;
        private bool ChucNangKhacisVisible = false;

        private void DefaultVisible()
        {
            this.buttonQuanLyPhim.Visible = true;
            this.buttonQuanLyRapChieu.Visible = true;
            this.buttonQuanLyNhanVien.Visible = true;
            this.buttonThongKe.Visible = true;
            this.buttonXepLichChieu.Visible = true;
            this.buttonChucNangKhac.Visible = true;

            this.buttonTKDoangThu.Visible = false;
            this.buttonTKKetQuaLamViecNhanVien.Visible = false;
            this.buttonThemDoiTuongMua.Visible = false;
            this.buttonThietLapMucGia.Visible = false;

            int y = this.buttonThongKe.Location.Y;
            this.buttonQuanLyPhim.Location = new Point(13, this.buttonThongKe.Location.Y + 42);
            this.buttonQuanLyRapChieu.Location = new Point(13, this.buttonThongKe.Location.Y + 42 * 2);
            this.buttonQuanLyNhanVien.Location = new Point(13, this.buttonThongKe.Location.Y + 42 * 3);
            this.buttonChucNangKhac.Location = new Point(13, this.buttonThongKe.Location.Y + 42 * 4);          
            this.buttonXepLichChieu.Location = new Point(13, this.buttonThongKe.Location.Y + 42 * 5);

            ThongKeisVisible = false;
            ChucNangKhacisVisible = false;

        }

        private void buttonQuanLyPhim_Click(object sender, EventArgs e)
        {
            DefaultVisible();
            if (EventQuanLyPhim != null)
            {
                EventQuanLyPhim();
            }
        }

        private void buttonQuanLyRapChieu_Click(object sender, EventArgs e)
        {
            DefaultVisible();
            if(EventQuanLyRapChieu!=null)
            {
                EventQuanLyRapChieu();
            }
        }

        private void buttonQuanLyNhanVien_Click(object sender, EventArgs e)
        {
            DefaultVisible();
            if(EventQuanLyNhanVien!=null)
            {
                EventQuanLyNhanVien();
            }
        }

        private void buttonTKDoangThu_Click(object sender, EventArgs e)
        {
            if(EventThongKeDoanhThu!=null)
            {
                EventThongKeDoanhThu();
            }
            
        }

        private void buttonTKKetQuaLamViecNhanVien_Click(object sender, EventArgs e)
        {
            if(EventThongKeKetQuaLamViec!=null)
            {
                EventThongKeKetQuaLamViec();
            }
        }

       
        private void ChucNangKhacVisible(bool visible)
        {
            if (visible == true)
            {
                int y = this.buttonThongKe.Location.Y;
                this.buttonTKDoangThu.Visible = false;
                this.buttonTKKetQuaLamViecNhanVien.Visible = false;
                this.buttonThemDoiTuongMua.Visible = true;
                this.buttonThietLapMucGia.Visible = true;

                this.buttonQuanLyPhim.Location = new Point(13, this.buttonThongKe.Location.Y + 42);
                this.buttonQuanLyRapChieu.Location = new Point(13, this.buttonThongKe.Location.Y + 42*2);
                this.buttonQuanLyNhanVien.Location = new Point(13, this.buttonThongKe.Location.Y + 42*3);
                this.buttonChucNangKhac.Location = new Point(13, this.buttonThongKe.Location.Y + 42*4);
                this.buttonThemDoiTuongMua.Location = new Point(13, this.buttonThongKe.Location.Y + 42*5);
                this.buttonThietLapMucGia.Location = new Point(13, this.buttonThongKe.Location.Y + 42*6);
                this.buttonXepLichChieu.Location = new Point(13, this.buttonThongKe.Location.Y + 42*7);
            }
            else
            {
                DefaultVisible();
            }
        }

        private void ThongKeVisible(bool visible)
        {
            if(visible==true)
            {
                int y = this.buttonThongKe.Location.Y;
                this.buttonTKDoangThu.Visible = true;
                this.buttonTKKetQuaLamViecNhanVien.Visible = true;
                this.buttonThemDoiTuongMua.Visible = false;
                this.buttonThietLapMucGia.Visible = false;

                this.buttonTKDoangThu.Location = new Point(13, y + 42);
                this.buttonTKKetQuaLamViecNhanVien.Location = new Point(13, y + 42 * 2);

                this.buttonQuanLyPhim.Location = new Point(13, this.buttonThongKe.Location.Y + 42 * 3);
                this.buttonQuanLyRapChieu.Location = new Point(13, this.buttonThongKe.Location.Y + 42 * 4);
                this.buttonQuanLyNhanVien.Location = new Point(13, this.buttonThongKe.Location.Y + 42 * 5);
                this.buttonChucNangKhac.Location = new Point(13, this.buttonThongKe.Location.Y + 42 * 6);
                this.buttonXepLichChieu.Location = new Point(13, this.buttonThongKe.Location.Y + 42 * 7);
            }
            else
            {
                DefaultVisible();
            }
        }

        private void UserControlMenuAdmin_Load(object sender, EventArgs e)
        {
            DefaultVisible();
        }

        //thiết lập mức giá 
        private void buttonThietLapMucGia_Click(object sender, EventArgs e)
        {
            if(EventThietLapMucGia!=null)
            {
                EventThietLapMucGia();
            }
        }

        //Thêm đối tượng mua
        private void buttonThemDoiTuongMua_Click(object sender, EventArgs e)
        {

            if(EventThemDoiTuongMua!=null)
            {
                EventThemDoiTuongMua();
            }
        }


        //Chức năng khác
        private void buttonChucNangKhac_Click(object sender, EventArgs e)
        {
            if (ChucNangKhacisVisible==false)
            {
                ChucNangKhacVisible(true);
                ChucNangKhacisVisible = true;
            }
            else
                ChucNangKhacVisible(false);
            
        }

        //Xếp lịch chiếu.
        private void buttonXepLichChieu_Click(object sender, EventArgs e)
        {
            if(EventXepLichChieu!=null)
            {
                EventXepLichChieu();
            }
        }



    }
}
